package com.it.service.impl;

import com.it.dao.AccountDao;
import com.it.pojo.Account;
import com.it.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("accountService")
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;

    @Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
    public List<Account> queryAll() {
      /*  ArrayList<Account> list = new ArrayList<Account>();
        list.add(new Account(1,"小新",200F));
        list.add(new Account(2,"风间",200F));*/

        List<Account> list = accountDao.queryAll();
        System.out.println("list = " + list);

        return list;
    }

    @Override
    public void add(Account account) {
        accountDao.add(account);
    }

    @Override
    public void delete(Integer id) {
        accountDao.delete(id);
    }

    @Override
    public void update(Account account) {
        accountDao.update(account);
    }


}
